-
-
Notifications
You must be signed in to change notification settings - Fork 827
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Replace usage of std::vector as storage of pixel data with image::Image #1282
Replace usage of std::vector as storage of pixel data with image::Image #1282
Conversation
@@ -395,7 +395,8 @@ void DepthSimMap::saveToImage(const std::string& filename, float simThr) const | |||
metadata.push_back(oiio::ParamValue("AliceVision:storageDataType", | |||
EStorageDataType_enumToString(image::EStorageDataType::Float))); | |||
image::writeImage(filename, colorBuffer, | |||
image::OutputFileColorSpace(image::EImageColorSpace::NO_CONVERSION), metadata); | |||
image::ImageWriteOptions().toColorSpace(image::EImageColorSpace::LINEAR), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Technical maps like depth, sim, etc have no notion of colorspace. In this case, we usually use NO_CONVERSION to make it explicit.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Previously OutputFileColorSpace
was setting both from
and to
to LINEAR if single-parameter constructor was used with NO_CONVERSION. This code preserves existing behavior.
See 4668fe1#diff-dc4ab367f585ae18a7872e28d2c057e6388eb99b2ff928a3a5295ffc0df14425L66
@@ -142,7 +142,8 @@ bool exportToMVE2Format( | |||
// Undistort and save the image | |||
readImage(srcImage, image, image::EImageColorSpace::NO_CONVERSION); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It's not something introduced in your PR.
But I do not understand why we have so much places where we explicitly specify a target colorspace for reading or writing images. The AUTO should be fine for (almost?) all cases.
It's probably for historical reason, before we introduced the AUTO...
In this particular case, it should clearly be AUTO else it can be completely wrong, as we read any format in input and we output in PNG. So it cannot be statically defined.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I agree.
Thinking again about this colorspace question. It would be great to make a cleanup.
|
0e17f33
to
0571b87
Compare
@fabiencastan I fully agree. I didn't want to make any changes to behavior in this PR because it's already large and figuring out what exactly broke would be a challenge. It makes sense to implement these recommendation in a next PR. |
All comments have been addressed. |
0571b87
to
b313aba
Compare
@fabiencastan Just a friendly ping :-) I have one resurrected test that depends on this PR being landed. |
Thanks @p12tic for this useful work! |
This PR is a continuation of #1257 in an attempt to clean up image interfaces.
Currently the codebase has roughly 2 ways to represent an image:
image::Image<T>
class andstd::vector<T>
plus width and height (there's alsoStaticVector<T>
but it hasstd::vector<T>
underneath). This is inefficient because this requires twice as many functions to cover the basic image functionality.This PR replaces usages of
std::vector<T>
withimage::Image<T>
at least in cases wherereadImage()
andwriteImage()
functions are used. This way it was possible to remove the set of functions that operates onstd::vector<T>
.writeImage()
now accepts configuration data viaImageWriteOptions
class. This was required because the function needed even more parameters to support all needed functionality and using class removed this requirement.ImageWriteOptions
uses builder pattern to supply options, so it's convenient to use, as common configuration cases can be declared as member functions.